package com.hj.dapp.config.exp;

import com.hj.dapp.common.resp.RestResp;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * @author 胡奥程
 * @version 1.0
 * @date 2023/12/29
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(BusinessErrorException.class)
    @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
    public RestResp<?> handleBusinessError(BusinessErrorException ex) {
        return RestResp.error(ex);
    }
    @ExceptionHandler(Exception.class)
    @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
    public RestResp<?> handleExpError(Exception ex) {
        ex.printStackTrace();
        return RestResp.error(ex.getMessage());
    }
}
